package main

import "fmt"

type person1 struct {
	name string
	sex  string
	age  int
}

type teacher struct {
	person1
	subject string
}

type student1 struct {
	person1
	score int
}

func (s *student1) sayHello() {
	fmt.Println(s)
}

func (s *teacher) sayHello() {
	fmt.Println(s)
}

//接口定义
//接口定义了规则,方法实现了规则
//接口是虚的,方法是实的
type Humaner interface {
	//方法只声明,没有具体的实现;具体的实现根据对象不同,实现方式也不同
	sayHello()
}

func main() {
	a := teacher{person1{"zs", "男", 12}, "语文"}
	a.sayHello()

	b := student1{person1{"ls", "男", 11}, 20}
	b.sayHello()

	var h Humaner
	h = &a //teacher struct必须实现了接口里的方法,否则会报错
	h.sayHello()

}
